cmake_minimum_required(VERSION 2.8)
#########################################################################

# Basic environment setting

if(WIN32)
	SET(BUILD_PROJECT_NAME "libvzsip")
elseif(UNIX)
	SET(BUILD_PROJECT_NAME "vzsip")
endif()

#########################################################################
#INCLUDE_DIRECTORIES(${LIBVZNET_INCLUDE_DIR})
MESSAGE(STATUS "Print the include directores")
get_property(inc_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(inc_dir ${inc_dirs})
  message(STATUS "    include directory='${inc_dir}'")
endforeach()

#########################################################################
#Step 2 : Add library directories
MESSAGE(STATUS "Step 2 : Add library directories")
#LINK_DIRECTORIES(${LIBVZNET_LIBRARY_DIR})
MESSAGE(STATUS "Print the link directores")
get_property(link_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY LINK_DIRECTORIES)
foreach(link_dir ${link_dirs})
  message(STATUS "    link directory='${link_dir}'")
endforeach()

#########################################################################
#Step 3 : Add code source

SET(SRC_LIST 
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipclient.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipclient.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipclientsettings.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipengineimpl.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipengine.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipengineimpl.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipengineimpl_iq.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsippump.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsippump.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsiptask.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsiptask.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipid.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipid.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/sipmessageconstants.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/sipmessagestanza.pb.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/sipmessagestanza.pb.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/clientlogintask.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/clientlogintask.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/serverlogintask.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/serverlogintask.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsiplogintask.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsiplogintask.cc
	
	#---------------------------------------------------------------------------
	${CMAKE_CURRENT_SOURCE_DIR}/client/sipclientsession.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/client/sipclientsession.h
	${CMAKE_CURRENT_SOURCE_DIR}/client/sipclientsessionmanager.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/client/sipclientsessionmanager.h
	
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/getinfortask.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/getinfortask.h
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/pingtask.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/pingtask.h
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/appconstants.h
	
	${CMAKE_CURRENT_SOURCE_DIR}/client/device/devicemessage.pb.h
	${CMAKE_CURRENT_SOURCE_DIR}/client/device/devicemessage.pb.cc
	#---------------------------------------------------------------------------
	
	${CMAKE_CURRENT_SOURCE_DIR}/server/vzsipservermanager.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/server/vzsipservermanager.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/servertask.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/servertask.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/server/serversession.h
	${CMAKE_CURRENT_SOURCE_DIR}/server/serversession.cpp
	#${CMAKE_CURRENT_SOURCE_DIR}/server/serverlogintask.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/serverlogintask.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/server/vzsipserver.h
	${CMAKE_CURRENT_SOURCE_DIR}/server/vzsipserver.cpp
	
	${CMAKE_CURRENT_SOURCE_DIR}/server/app/pongtask.h
	${CMAKE_CURRENT_SOURCE_DIR}/server/app/pongtask.cpp
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipcctask.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipcctask.cpp
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipccconstant.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipccstruct.pb.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipccstruct.pb.cc
	
	${CMAKE_CURRENT_SOURCE_DIR}/task/taskparent.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/task/taskparent.h
	${CMAKE_CURRENT_SOURCE_DIR}/task/taskrunner.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/task/taskrunner.h
	${CMAKE_CURRENT_SOURCE_DIR}/task/task.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/task/task.h
	
	${CMAKE_CURRENT_SOURCE_DIR}/base/basictypes.h
	${CMAKE_CURRENT_SOURCE_DIR}/base/basicdefines.h
	${CMAKE_CURRENT_SOURCE_DIR}/base/timeutils.h
	${CMAKE_CURRENT_SOURCE_DIR}/base/timeutils.cc
	
	#${CMAKE_CURRENT_SOURCE_DIR}/net/asyncsocket.h
	#${CMAKE_CURRENT_SOURCE_DIR}/net/asyncsocket.cpp
	)
	
# ------------------------------------------------------------------------------
SOURCE_GROUP(client FILES
	${CMAKE_CURRENT_SOURCE_DIR}/client/sipclientsession.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/client/sipclientsession.h
	${CMAKE_CURRENT_SOURCE_DIR}/client/sipclientsessionmanager.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/client/sipclientsessionmanager.h
)

SOURCE_GROUP(client\\app FILES
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/getinfortask.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/getinfortask.h
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/pingtask.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/pingtask.h
	${CMAKE_CURRENT_SOURCE_DIR}/client/app/appconstants.h
)
SOURCE_GROUP(client\\device FILES
	${CMAKE_CURRENT_SOURCE_DIR}/client/device/devicemessage.pb.h
	${CMAKE_CURRENT_SOURCE_DIR}/client/device/devicemessage.pb.cc
)
# ------------------------------------------------------------------------------

SOURCE_GROUP(server FILES
	${CMAKE_CURRENT_SOURCE_DIR}/server/vzsipservermanager.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/server/vzsipservermanager.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/servertask.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/servertask.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/server/serversession.h
	${CMAKE_CURRENT_SOURCE_DIR}/server/serversession.cpp
	#${CMAKE_CURRENT_SOURCE_DIR}/server/serverlogintask.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/serverlogintask.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/server/vzsipserver.h
	${CMAKE_CURRENT_SOURCE_DIR}/server/vzsipserver.cpp
)


SOURCE_GROUP(server\\app FILES
	${CMAKE_CURRENT_SOURCE_DIR}/server/app/pongtask.h
	${CMAKE_CURRENT_SOURCE_DIR}/server/app/pongtask.cpp
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipcctask.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipcctask.cpp
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipccconstant.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipccstruct.pb.h
	#${CMAKE_CURRENT_SOURCE_DIR}/server/app/ipccstruct.pb.cc
)

SOURCE_GROUP(core FILES
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipclient.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipclient.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipclientsettings.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipengineimpl.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipengine.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipengineimpl.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipengineimpl_iq.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsippump.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsippump.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsiptask.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsiptask.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipid.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsipid.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/sipmessageconstants.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/sipmessagestanza.pb.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/sipmessagestanza.pb.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/clientlogintask.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/clientlogintask.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/serverlogintask.cc
	${CMAKE_CURRENT_SOURCE_DIR}/core/serverlogintask.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsiplogintask.h
	${CMAKE_CURRENT_SOURCE_DIR}/core/vzsiplogintask.cc
)
SOURCE_GROUP(task FILES
	${CMAKE_CURRENT_SOURCE_DIR}/task/taskparent.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/task/taskparent.h
	${CMAKE_CURRENT_SOURCE_DIR}/task/taskrunner.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/task/taskrunner.h
	${CMAKE_CURRENT_SOURCE_DIR}/task/task.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/task/task.h
)

SOURCE_GROUP(base FILES
	${CMAKE_CURRENT_SOURCE_DIR}/base/basictypes.h
	${CMAKE_CURRENT_SOURCE_DIR}/base/basicdefines.h
	${CMAKE_CURRENT_SOURCE_DIR}/base/timeutils.h
	${CMAKE_CURRENT_SOURCE_DIR}/base/timeutils.cc
)

#SOURCE_GROUP(net FILES
#	${CMAKE_CURRENT_SOURCE_DIR}/net/asyncsocket.h
#	${CMAKE_CURRENT_SOURCE_DIR}/net/asyncsocket.cpp
#)
#########################################################################
#Step 4 : Add PROJECT define 
MESSAGE(STATUS "Step 4 : Add code source")

#########################################################################
#Step 5 : Add executable or library target
MESSAGE(STATUS "Step 5 : Add executable or library target")
#ADD_executable(${BUILD_PROJECT_NAME} ${SRC_LIST})
ADD_LIBRARY(${BUILD_PROJECT_NAME} STATIC ${SRC_LIST})
set_property(TARGET ${BUILD_PROJECT_NAME} PROPERTY FOLDER ${PROJECT_SET_NAME_LIB})
#########################################################################
#Step 6 : link with other library
MESSAGE(STATUS "Step 6 : link with other library")

TARGET_LINK_LIBRARIES(${BUILD_PROJECT_NAME} 
	${VZPROJECT_LINK_LIB}
)